package com.multimedia.room;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;

public class KillProcessUtils {
	public static final String WPS_OFFICE_PKG= "cn.wps.moffice_i18n_TV";
	public static final String FIREPLAYER_PKG= "com.softwinner.fireplayer";
	public static final String BROWSER_PKG= "com.android.browser";
	public static final String ADOBE_PKG= "com.adobe.reader";
	private String[] KILL_PKGS = new String[]{WPS_OFFICE_PKG,FIREPLAYER_PKG,BROWSER_PKG,ADOBE_PKG};
	private static KillProcessUtils sKillProcessUtils = new KillProcessUtils();
	
    private KillProcessUtils() {

    }

    public static KillProcessUtils getInstance() {
        if (sKillProcessUtils == null) {
            return new KillProcessUtils();
        } else {
            return sKillProcessUtils;
        }
    }

    
	public void killProcess(Context context) {
		for(String pkg : KILL_PKGS){
			
		try {
			ActivityManager activityManager = (ActivityManager) context
					.getSystemService(Context.ACTIVITY_SERVICE);
			Method forceStopPackage;
			forceStopPackage = activityManager.getClass().getDeclaredMethod(
					"forceStopPackage", String.class);

			forceStopPackage.setAccessible(true);
			forceStopPackage.invoke(activityManager, pkg);
		} catch (NoSuchMethodException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	}
}
